import request from "../utils/request";

export function userList(bean) {
    return request({
        url: "user/users",
        method: 'get',
        params: {
            ...bean
        }
    })
}

export function getUserById(id) {
    return request({
        url: "user/get/" + id,
        method: 'get',
    })
}


export function addUser(user) {
    return request({
        url: "user/add",
        method: 'post',
        data: {
            ...user
        }
    })
}

export function deleteUser(id) {
    return request({
        url: "user/delete",
        method: 'post',
        data: {
            id
        }
    })
}

export function deleteUsers(ids) {
    return request({
        url: "user/deletes",
        method: 'post',
        data: {
            ids
        }
    })
}

export function updateUser(user) {
    return request({
        url: "user/update",
        method: 'post',
        data: {
            ...user
        }
    })
}


export function resetPassword(username, password) {
    return request({
        url: "user/resetPassword",
        method: 'post',
        data: {
            username,
            password
        }
    })
}

export function userExport(ids) {
    return request({
        url: "user/export",
        method: 'post',
        responseType: "blob",
        data: {
            ids
        }
    })
}

export function getImportExcel() {
    return request({
        url: "questionBank/getImportExcel",
        method: 'post',
        responseType: "blob",
    })
}

export function selfUpdate(bean) {
    return request({
        url: "user/self/update",
        method: 'post',
        data: {
            ...bean
        }
    })
}

export function selfResetPsw(oldPassword, newPassword) {
    return request({
        url: "user/self/resetPsw",
        method: 'post',
        data: {
            oldPassword,
            newPassword
        }
    })
}
